<?php

namespace App\Console\Commands;

use App\Admin\Repositories\SignUpJobPosition;
use App\Models\DayStatisticsModel;
use App\Models\DistrictModel;
use App\Models\SignUpJobpositionModel;
use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;

class JobPositionRecruitNum extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:job-recruit-num';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '重新计算报名人数';

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        foreach (\App\Models\JobpositionModel::query()->get() as $res) {
            $count = SignUpJobpositionModel::query()->where('job_position_id',$res->id)->count();
            $res->update([
                'recruit_num'=>$count
            ]);
    }
        $this->info('计算结束');
    }
}